package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC917 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String reverseOnlyLetters(String s) {
            char[] cs = s.toCharArray();
            int n = cs.length;
            for (int i = 0, j = n - 1; i < j; ) {
                while (i < j && !Character.isLetter(cs[i])) i++;
                while (i < j && !Character.isLetter(cs[j])) j--;
                if (i < j) {
                    char c = cs[i];
                    cs[i++] = cs[j];
                    cs[j--] = c;
                }
            }
            return String.valueOf(cs);
        }
    }


    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC917 an = new LC917();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
